﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace PongGame
{
    public class PongController
    {
        Bat LeftBat;
        Bat RightBat;
        Ball Ball;
        Texture2D Bat_Texture;
        Texture2D Ball_Texture;
        public PongController()
        {
            LeftBat = new Bat(50,0);
            RightBat = new Bat(700,0);
            Ball = new Ball(400,300,RightBat,LeftBat);
        }

    
        public void Draw(SpriteBatch Screen)
        {
            LeftBat.Draw(Screen,Bat_Texture);
            RightBat.Draw(Screen, Bat_Texture);
            Ball.Draw(Screen, Ball_Texture);
        }

        public void Update()
        {
            Input();
            Ball.Update();
        }

        internal void Input()
        {
            KeyboardState keyboardState = Keyboard.GetState();
            if (keyboardState.IsKeyDown(Keys.Up))
            {
                RightBat.GoUp();
            }
             
            if (keyboardState.IsKeyDown(Keys.Down))
                {
                    RightBat.GoDown();
                }

            if (keyboardState.IsKeyDown(Keys.W))
                {
                    LeftBat.GoUp();
                }

            if (keyboardState.IsKeyDown(Keys.S))
            {
                LeftBat.GoDown();
            }
            }

        public void LoadGraphics(Main Game)
        {
            Bat_Texture = Game.Content.Load<Texture2D>(@"Bat");
            Ball_Texture = Game.Content.Load<Texture2D>(@"ball");
        }
    }
}
